﻿//-----------------------------------------------------------------------
// <copyright file="WindowHelpers.cs" company="AFS">
// Copyright (c) AFS. All rights reserved.
//
//    This file is part of Chatbox.
//
//    Chatbox is free software: you can redistribute it and/or modify
//    it under the terms of the GNU Lesser General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    any later version.
//
//    Chatbox is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with Chatbox. If not, see http://www.gnu.org/copyleft/lesser.html
// </copyright>
//----------------------------------------------------------------------- 
namespace ChatBox.UI
{
    using System.Windows;

    /// <summary>
    /// Helper methods for windows
    /// </summary>
    public static class WindowHelpers
    {
        /// <summary>
        /// Set the window position from the rect
        /// </summary>
        /// <param name="window">the window to set</param>
        /// <param name="windowDimensions">the dimensions</param>
        public static void SetWindowPosition(this Window window, Rect windowDimensions)
        {
            if ((windowDimensions.Top >= 0) && (windowDimensions.Left >= 0) &&
                (windowDimensions.Width > 0) && (windowDimensions.Height > 0))
            {
                window.Top = windowDimensions.Top;
                window.Left = windowDimensions.Left;
                window.Width = windowDimensions.Width;
                window.Height = windowDimensions.Height;
            }
        }
    }
}
